package com.bj58.ecdata.dashboard.controllers;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;

import com.bj58.ecdata.dashboard.databll.ResumeBLL;
import com.bj58.ecdata.dashboard.utils.MyServletRequestUtils;
import com.bj58.wf.mvc.ActionResult;
import com.bj58.wf.mvc.MvcController;
import com.bj58.wf.mvc.annotation.POST;
import com.bj58.wf.mvc.annotation.Path;

/**
 * 简历看板 Ajax Controller
 * @author zhaoxiang 2015-08-19
 */
@Path("/resume/ajax")
public class ResumeAjaxController extends MvcController{
	
	@Path("/getResumeTotal")
	@POST
	public ActionResult getResumeTotal() {

		HttpServletRequest request = beat.getRequest();
		
		String cate = MyServletRequestUtils.getStringParameter(request, "cate_option", "");
		String city = MyServletRequestUtils.getStringParameter(request, "city_option", "");
		String index = MyServletRequestUtils.getStringParameter(request, "index_Type", "");

		try {
			
			String data = ResumeBLL.getResumeTotalJson(cate,city,index);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}

	
	@Path("/getResumeTotalLine")
	@POST
	public ActionResult getResumeTotalLine() {

		String cate = beat.getRequest().getParameter("cate_option");
		String city = beat.getRequest().getParameter("city_option");
		String index = beat.getRequest().getParameter("index_Type");
		try {
			
			String data = ResumeBLL.getResumeTotalLineJson(cate,city,index);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	
	@Path("/getJobTotal")
	@POST
	public ActionResult getJobTotal() {

		String cate = beat.getRequest().getParameter("cate_option");
		String city = beat.getRequest().getParameter("city_option");
		String index = beat.getRequest().getParameter("index_Type");
		try {
			
			String data = ResumeBLL.getJobTotalJson(cate,city,index);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}

	
	@Path("/getJobTotalLine")
	@POST
	public ActionResult getJobTotalLine() {

		String cate = beat.getRequest().getParameter("cate_option");
		String city = beat.getRequest().getParameter("city_option");
		String index = beat.getRequest().getParameter("index_Type");
		try {
			
			String data = ResumeBLL.getJobTotalLineJson(cate,city,index);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	
	@Path("/getDownSubject")
	@POST
	public ActionResult getDownSubject() {

		String cate = beat.getRequest().getParameter("cate_option");
		String city = beat.getRequest().getParameter("city_option");
		String index = beat.getRequest().getParameter("index_Type");
		try {			
					
			String data = ResumeBLL.getDownSubjectJson(cate,city,index);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	@Path("/getResumeIncome")
	@POST
	public ActionResult getResumeIncome() {
		
		String name_type = beat.getRequest().getParameter("name_type");
		try {
			
			String data = ResumeBLL.getResumeIncomeJson(name_type);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	@Path("/getResumeIncomebar")
	@POST
	public ActionResult getResumeIncomebar() {

		String index = beat.getRequest().getParameter("index_Type");
		String name_type = beat.getRequest().getParameter("name_type");
		try {
			
			String data = ResumeBLL.getResumeIncomebarJson(index,name_type);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	@Path("/getResumeQuantity")
	@POST
	public ActionResult getResumeQuantity() {

		String dateGroup = beat.getRequest().getParameter("dateGroup");
		String city = beat.getRequest().getParameter("city_option");
		String cate = beat.getRequest().getParameter("cate_option");	
		String beginDate = beat.getRequest().getParameter("beginDate");	
		try {
			
			String data = ResumeBLL.getResumeQuantityJson(city,cate,dateGroup,beginDate);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	@Path("/getResumeEntWord")
	@POST
	public ActionResult getResumeEntWord() {

		String city = beat.getRequest().getParameter("city_option");
		String cate = beat.getRequest().getParameter("cate_option");	
		String beginDate = beat.getRequest().getParameter("beginDate");
		
		beginDate="2015-08-03";
		try {
			
			String data = ResumeBLL.getResumeEntWordJson(city,cate,beginDate);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	@Path("/getResumeZifuyun")
	@POST
	public ActionResult getResumeZifuyun() {

		String city = beat.getRequest().getParameter("city_option");
		String cate = beat.getRequest().getParameter("cate_option");	
		String beginDate = beat.getRequest().getParameter("beginDate");
		
		beginDate="2015-08-03";
		try {
			
			String data = ResumeBLL.getResumeZifuyunJson(city,cate,beginDate);

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	@POST
	@Path("/readDownLoad")
	public ActionResult readDownLoad() {
		try {
			HttpServletRequest request = beat.getRequest();
			String dateGroup = MyServletRequestUtils.getStringParameter(request, "dateGroup", "stat_date");
			String city = MyServletRequestUtils.getStringParameter(request, "city_readDown", "");
			String cate = MyServletRequestUtils.getStringParameter(request, "cate_readDown", "");
			String cycle = MyServletRequestUtils.getStringParameter(request, "index_readDown", "");
			String data = ResumeBLL.getReadDownData(dateGroup,city,cate,cycle);
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ActionResult.view("null");
		}
	}
	
	@POST
	@Path("/qualityMatch")
	public ActionResult qualityMatch() {
		try {
			HttpServletRequest request = beat.getRequest();
			String dateGroup = MyServletRequestUtils.getStringParameter(request, "dateGroup", "stat_date");
			String statType = MyServletRequestUtils.getStringParameter(request, "statType", "");
			String dateVal = MyServletRequestUtils.getStringParameter(request, "dateVal", "");
			String city = MyServletRequestUtils.getStringParameter(request, "city", "");
			String cate = MyServletRequestUtils.getStringParameter(request, "cate", "");
			String education = MyServletRequestUtils.getStringParameter(request, "education", "");
			String salary = MyServletRequestUtils.getStringParameter(request, "salary", "");
			String workYears = MyServletRequestUtils.getStringParameter(request, "workYears", "");
			
			String chartType = MyServletRequestUtils.getStringParameter(request, "chartType", "");
			
			String data = null;
			if(StringUtils.equals(chartType, "radar")){
				data = ResumeBLL.getQualityRadarData(dateGroup,statType,dateVal,city,cate,education,salary,workYears);
			}else{
				data = ResumeBLL.getQualityLineData(dateGroup,statType,city,cate,education,salary,workYears);
			}

			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ActionResult.view("null");
		}
	}
	

	@POST
	@Path("/talentinflow")
	public ActionResult getTalentInflow() {
		try {
			HttpServletRequest request = beat.getRequest();
			String dateGroup = MyServletRequestUtils.getStringParameter(request, "datetype", "");
			String city = MyServletRequestUtils.getStringParameter(request, "city_option", "");
			String cate = MyServletRequestUtils.getStringParameter(request, "cate_option", "");
			String seldate = MyServletRequestUtils.getStringParameter(request, "selDate", "");			
			String data = ResumeBLL.getTalentInflowData(dateGroup,city,cate,seldate);	
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ActionResult.view("null");
		}
	}
	
}
